<!doctype html>
<html>
<head>
    <meta charset="utf-8">
    <title>收货地址-{$tpshop_config['shop_info_store_title']}</title>
    <meta http-equiv="keywords" content="{$tpshop_config['shop_info_store_keyword']}" />
    <meta name="description" content="{$tpshop_config['shop_info_store_desc']}" />
    <link rel="stylesheet" href="__STATIC__/css/edit_address.css" type="text/css">
    <script src="__PUBLIC__/js/jquery-1.10.2.min.js"></script>
<!--     <script src="__STATIC__/js/slider.js"></script> -->
	<script src="__PUBLIC__/js/layer/layer-min.js"></script><!--弹窗js 参考文档 http://layer.layui.com/-->
</head>
<style type="text/css">
.wi80-BFB{width:80%}
.wi40-BFB{width:40%}
.seauii{ padding:7px 10px; margin-right:10px}
.he110{ height:110px}
.di-bl{ display:inherit}
/* votebox */
.votebox{width:400px;margin:0 auto;text-align:left;position:relative;z-index:66;}
/* barbox */
.barbox{height:10px;line-height:10px;overflow:hidden;}
.barbox dt a{color:#0048CC;}
.votebox dl{ -webkit-margin-before: 0em;-webkit-margin-after: 0em;}
.barbox dd{float:left;-webkit-margin-start:0px;}
.barbox dd.last{color:#999;}
.barbox dd.barline{width:400px;background:#ccc;height:10px;overflow:hidden;display:inline;border-radius:10px ;}
.barbox dd.barline div.charts{height:10px;overflow:hidden;background:red;border-radius:10px;}
</style>
<body>
<div class="adderss-add">
    <div class="ner-reac ol_box_4" style="visibility: visible; position: fixed; z-index: 500; width: 100%; height:100%">
        <div class="box-ct">
            <div class="box-header">
                <!-- <a href="" class="box-close"></a> -->
            </div>
            <form action="{:U('Admin/User/doSendMessage')}" method="post" id="messageform" onSubmit="return checkForm()">
                <table width="90%" border="0" cellspacing="0" cellpadding="0">
                    <input name="call_back" type="hidden" value="call_back" />
                    <tr class="postmessage" style=" height:32px">
                        <td></td>
                        <td>
                            <if condition="count($users) gt 0"><input id="allvip" type="radio"checked="checked" name="type" value="0"><label for="allvip"  class="allvip">发送给以下会员</label></if>
                            <input id="someonevip" type="radio" <if condition="count($users) eq 0">checked="checked"</if> name="type" value="1"><label for="someonevip">发送给全部会员</label>
                        </td>
                    </tr>
                    <if condition="count($users) gt 0">
                     <tr>
                    	<td align="right" valign="top">会员列表：</td>
                    	<td>
                            <div class="wi80-BFB re-no viplist" >
                                <volist name="users" id="user">
                                    <input type="hidden" name="user[]" value="{$user['user_id']}" />
                                    <p><span>{$user['user_id']}</span>&nbsp;<span>{$user['nickname']}</span></p>
                                </volist>
                            </div>
                        </td>
                    </tr>
                    </if>
                    <tr>
                        <td><div>&nbsp;</div></td>
                        <td><div>&nbsp;</div></td>
                    </tr>
                    <tr>
                        <td align="right" valign="top">发送内容：</td>
                        <td><textarea class="he110 wi80-BFB re-no" name="text" id="text" placeholder="发送内容" maxlength="100"></textarea></td>
                    </tr>
                    <tr style="height:100px"> 
                        <td align="right" valign="top">发送链接：</td>
                        <td><textarea class="he110 wi80-BFB re-no" name="messageurl" id="messageurl" placeholder="消息链接"></textarea></td>
                    </tr>
                     <tr style="height:60px">
                        <td class="pa-50-0">&nbsp;</td>
                        <td align="right">
                            <button type="button" style="padding: 4px 16px;cursor: pointer;" id="send"><span>发送</span></button>
                        </td>    
                    </tr>
                </table>
               	
            </form>
        </div>
        <div class="votebox">
			<dl class="barbox">
				<dd class="barline">
					<div w="50" style="width:0px;" class="charts"></div>
				</dd>
			</dl>
		</div>
    </div>
</div>
<!-- <script src="__PUBLIC__/js/global.js"></script> -->
<!-- <script src="__PUBLIC__/js/pc_common.js"></script> -->

<script>
    function checkForm(){
        var text = $('#text').val();
        var error = '';
        if(text == ''){
            error += '站内信内容不能为空 <br/>';
        }
        if(error){
			layer.alert(error, {icon: 2});
            return false;
        }
        return true;
    }
    
    $(function(){
    	$("#send").click(function(){
    		if($('input:radio[name="type"]:checked').val() == 0){
    			$("#messageform").submit();
    			return;
    		}
    		setSendSMSProgress(phoneLength,0);
    		return false;
    	});
    });
    var phoneLength={$user_count};//总条数;
    function setSendSMSProgress(phoneLength,datanum){
        var text = $("#text").val();//消息内容
        var messageurl = $("#messageurl").val();//消息链接
        	$.ajax({  
            	type:'POST',
            	url:'/admin/user/doSendMessage',  
   				data:{'datanum':datanum,'type':1,'text':text,'messageurl':messageurl,'datanum':datanum},
   				dataType:"json",
           	 	success:function(data){
                	if(parseInt(data) < phoneLength){  
                    	var aaa = parseInt(parseInt(data) / phoneLength * 100);  
                    	$(".charts").each(function(i,item){
							$(item).animate({
								width: aaa+"%"
							},100);
						});
                    	setSendSMSProgress(phoneLength,data);
                	}else{  
                		var aaa = parseInt(parseInt(data) / phoneLength * 100);  
                    	$(".charts").each(function(i,item){
							$(item).animate({
								width: aaa+"%"
							},100);
						});
                	} 
            	},  
            	error:function(){  
                	console.log('error');  
            	}
        	}); 
        	 
	}
</script>
</body>
</html>
